import cv2
import numpy as np

img = cv2.imread("d:\\test\\test.jpg", 0)

ret, thresh = cv2.threshold(img, 127, 255, 0)
contours, hierarchy, _ = cv2.findContours(thresh, 1, 2)
cnt = contours[0]
M = cv2.moments(cnt)

# 重心
cx = int(M['m10'] / M['m00'])
cy = int(M['m01'] / M['m00'])
# 面积
area = cv2.contourArea(cnt)
# 周长
perimeter = cv2.arcLength(cnt, True)

# 近似轮廓
epsilon = 0.1 * cv2.arcLength(cnt, True)
approx = cv2.approxPolyDP(cnt, epsilon, True)
